package cn.tedu.spring.eg3;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author lhd
 * @date 2024/4/17
 * @apiNote
 */
@Component
public class ShopController {
    private String shopService;

    public ShopController(){
        System.out.println("1.无参构造方法实例化");
    }

    @Value("出售饮料")
    public void setShopService(String shopService) {
        System.out.println("2.set方法给属性赋值");
        this.shopService = shopService;
    }

    @PostConstruct
    public void init() {
        System.out.println("3.使用注解 @PostConstruct 初始化");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("5.使用注解@PreDestroy 销毁");
    }

}
